<!--
 * @Description:
 * @Version: 2.0
 * @Autor: huangfu
 * @Date: 2020-12-18 09:57:40
 * @LastEditors: 大司马
 * @LastEditTime: 2020-12-21 09:40:24
-->
<template>
  <div class="qrcode" ref="qrCodeUrl"></div>
</template>

<script>
import QRCode from 'qrcodejs2'
export default {
  methods: {
    creatQrCode () {
      var qrcode = new QRCode(this.$refs.qrCodeUrl, {
        text: 'http://www.baidu.com', // 需要转换为二维码的内容
        width: 100,
        height: 100,
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      })
    }
  },
  mounted () {
    this.creatQrCode()
    this.$nextTick(() => {
      let [ canvas, img ] = this.$refs.qrCodeUrl.childNodes
    })
  },
  down () {

  }
}
</script>

<style lang="scss" scoped>
.qrcode{
    display: inline-block;
    img {
        width: 132px;
        height: 132px;
        background-color: #fff;
        padding: 6px;
        box-sizing: border-box;
    }
}
</style>
